package com.example.demo.equipment.controller;

import com.example.demo.equipment.dao.CollectingDevice;
import com.example.demo.equipment.service.CollectingDeviceService;
import com.example.demo.system.utility.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据采集设备
 */
@RequestMapping("device")
@RestController
public class CollectingDeviceController {

    @Autowired
    private CollectingDeviceService collectingDeviceService;

    @RequestMapping("getList")
    public Result getList(@RequestParam(value = "pageNum")Integer pageNum,
                          @RequestParam(value = "pageSize")Integer pageSize,
                          @RequestParam(value = "name", required = false)String name){
        return collectingDeviceService.getList(pageNum,pageSize,name);
    }

    @RequestMapping("getBindList")
    public Result getBindList(@RequestBody List<Integer> ids){
        return collectingDeviceService.getBindList(ids);
    }

    @RequestMapping("get")
    public Result get(Integer id){
        return Result.success(collectingDeviceService.get(id));
    }

    @RequestMapping("add")
    public Result add(@RequestBody CollectingDevice collectingDevice){
        return collectingDeviceService.add(collectingDevice);
    }

    @RequestMapping("update")
    public Result update(@RequestBody CollectingDevice collectingDevice){
        return collectingDeviceService.update(collectingDevice);
    }

    @RequestMapping("delete")
    public Result delete(Integer id){
        return collectingDeviceService.delete(id);
    }

}
